var edit_data = null;
var editable = null;
var config_hide_frame_left = <?=$config_hide_frame_left?"true":"false"?>;
<? if($editable) { ?>
editable = <?=json_encode($editable)?>;
<? } ?>
var editable_o = null;
<? if($config_rsa_pubkey) { ?>
var rsa_pubkey = "<?=str_replace("\n", "\\n", $config_rsa_pubkey)?>";
<? } ?>
var config_prefix = '<?=$config_prefix?>';

var showtype = '';
var search_items = false;
var editheight = 0;
var editparam = '';
var show_loading = '';
var isphone = <?=$isphone?"true":"false"?>;

function setSize() {
	if(!$("uploadifr")) {
		var iframe = document.createElement("iframe");
		iframe.id = 'uploadifr';
		iframe.name = 'uploadifr';
		iframe.setAttribute("frameborder", 'no');
		iframe.setAttribute("width", '1');
		iframe.setAttribute("height", '1');
		document.body.appendChild(iframe);
	
	}
	<? if($in_ifr) echo 'return ;'; ?>



	var height = document.documentElement.clientHeight;
	if(height == 0) height = document.body.clientHeight;
	
	var width = document.documentElement.clientWidth;
	if(width == 0) width = document.body.clientWidth;

	<? if($config_footer) { ?>
		height -= 26;
		$("footer_div").style.top = height + 'px';
	<? } ?>

	<? if(!$isphone) {?>


	$("leftDiv").style.height = (height-<?=$config_hide_frame_top?"0":"55"?>) + 'px';
	$("menus_div").style.height = (height-<?=$config_hide_frame_top?"45":"100"?>) + 'px';
	$("mainDiv").style.height = (height-<?=$config_hide_frame_top?"20":"75"?>) + 'px';
	

	if(config_hide_frame_left) {
		$("leftDiv").style.display = 'none';
		$("mainDiv").style.left = '0px';
		$("mainDiv").style.width = (width-20) + 'px';
	} else {
		$("mainDiv").style.width = (width-250) + 'px';
	}

	<? } else {?>

	var lheight = $("leftDiv").offsetHeight;

	$("mainDiv").style.top = (<?=$config_top_height?>+lheight) + 'px';
	$("mainDiv").style.height = (height-<?=$config_top_height?>-lheight-20) + 'px';
	$("mainDiv").style.width = (width-20) + 'px';

	$("leftDiv").style.width = (width-35) + 'px';
	$("leftDiv_more").style.left = (width-34) + 'px';
	if($("fdiv_menus")) $("fdiv_menus").style.left = (width-170) + 'px';
	<? } ?>

}
<? if($config_force_https) { ?>
var href = location.href+"";
if(href.toLowerCase().indexOf("http://") != -1) {
	href = href.replace("http://", "https://");
	location.href = href;
}
<? } ?>
function page_onload() {
	
	setSize();
	<? if($in_ifr) echo 'return ;'; ?>
	$G.ajax("?act=getMenus", {}, function(rs) {
		if(!check_rs(rs)) return ;
		<? if(!$isphone) { ?>
		$("menus_div").innerHTML = rs.data.menus_html;
		<? } else { ?>
		$("leftDiv").innerHTML = rs.data.menus_html;
		$("fdiv_menus").innerHTML = rs.data.menus_html.replace(/menua_/g, "menua2_");
		<? } ?>
		$("topDiv").innerHTML = rs.data.top_html;
		if(rs.data.title && ((document.title+'') != rs.data.title)) document.title = rs.data.title;
		open_showtype(rs.data.first_showtype);
		setNowMenu(rs.data.firstMenuN);
		setSize();
		<? if($config_openjs) {
			echo $config_openjs;
		} ?>
		window.adminInfo = rs.data.adminInfo;
		if(rs.data.config_hide_frame_left === 0 && $("leftDiv").style.display == 'none') {
			config_hide_frame_left = false;
			$("leftDiv").style.display = '';
			var w = $("mainDiv").style.width.replace('px', '');
			$("mainDiv").style.left = 231+'px';
			$("mainDiv").style.width = (w-231)+'px';
			
		}
	}, 'json', 'POST');
}
if(window.addEventListener) {
	window.addEventListener('load', page_onload, false);
} else {
	window.attachEvent('onload', page_onload);
}
window.onresize = function() {
	setSize();
	<? if($in_ifr) echo 'return ;'; ?>
	
	var ids = ['fdiv', 'fdiv_alert', 'fdiv_ifr'];
	for(var i in ids) {
		var id = ids[i];
		var cover_id = false;
		var zidx = false;
		if($(id).style.display != 'none') {
			var w = $(id).offsetWidth;
			var h = $(id).offsetHeight;
			<? if($isphone) { ?>
				if(id != 'fdiv_alert') {
					h = parseInt(document.documentElement.clientHeight*0.9);
					$("fdiv").style.height = h + 'px';
					$("fdiv_1").style.height = (h-40) + 'px';
				}
			<? } ?>
			if(id == 'fdiv_ifr') {
				cover_id = 'ifr_cover';
				zidx = 16;
			} else if(id == 'fdiv_alert') {
				cover_id = 'cover_alert';
				zidx = 19;
			}

			$G.show_div(id, w, h, cover_id, zidx);
		}
	}
}
<? if($isios) { ?>
window.addEventListener('focusin', () => {  //软键盘弹起事件
	var ch = document.documentElement.clientHeight - 260;
	$("fdiv").style.height = ch + 'px';
	$("fdiv_1").style.height = (ch-40) + 'px';
	document.body.scrollTop = 0;

});
window.addEventListener('focusout', () => {  //软键盘弹起事件
	var ch = parseInt(document.documentElement.clientHeight*0.9);
	$("fdiv").style.height = ch + 'px';
	$("fdiv_1").style.height = (ch-40) + 'px';
	document.body.scrollTop = 0;
});
<? } ?>
function hideIfrInfo() {
	$("fdiv_ifr_id").src = "about:blank";
	$G.hide_div("fdiv_ifr", true, 'ifr_cover');
}


function hideInfo() {
	$G.hide_div("fdiv");
	try{
		afterCloseInfo();
	} catch (e){}
	hide_text_select();
}


var lastMenu = 0;
function setNowMenu(n) {
	<? if(!$isphone) { ?>
	$("menua_"+lastMenu).style.backgroundColor = '';
	$("menua_"+n).style.backgroundColor = '#F2F2F2';
	<? } else { ?>
	$("menua_"+lastMenu).className = 'button1';
	$("menua_"+n).className = 'button2';

	$("menua2_"+lastMenu).className = 'button1';
	$("menua2_"+n).className = 'button2';

	try{
		$("menua_"+n).scrollIntoView({ behavior: 'smooth', block: 'nearest' });
	} catch (e){}

	hideMenus();
	<? } ?>
	lastMenu = n;
}


function checkUpload(fname, name, resize, allowExts) {
	var form = document.forms[fname];
	var fn = form.file.value;
	//var bt = $("ubt_" + fname);

	if(fn == '') {
		if(allowExts != '') alert("请选择要上传的文件！");
		else alert("请选择要上传的图片文件！");
		return ;
	}
	var a = fn.split(".");
	if(a.length < 2) {
		alert("文件错误！");
		form.file.value = '';
		return ;
	}
	var ext = a[a.length-1].toLowerCase();

	if(allowExts != '') {
		var a = allowExts.split("|");
		var suc = false;
		for(var i in a) {
			var ext2 = a[i].toLowerCase();
			if(ext == ext2) {
				suc = true;
				break;
			}
		}
		if(!suc) {
			alert("只支持上传指定类型("+a.join(",")+")文件！");
			form.file.value = '';
			return ;
		}
	} else {
		if(ext != 'jpg' && ext != 'png' && ext != 'jpeg') {
			alert("只支持上传jpg、png格式图片！");
			form.file.value = '';
			return ;
		}
	}
	$("div_"+fname).style.display = 'none';
	$("fname_" + name).innerHTML = '正在上传...';
	if(resize && resize != '') {
		var a = form.file.files;
		var reader = new FileReader();
		reader.readAsDataURL(a[0]);
		reader.onload=function (e) {
			var data = e.target.result;
			var einfo = __EXIF.readFromBinaryFile(data);
			var ori = einfo['Orientation'];
			var img = new Image();
			img.src = data;
			img.onload=function (){
				
				var maxsize = parseInt(resize);
				if(img.width > maxsize || img.height > maxsize) {
					var canvas = document.createElement('canvas');
					var ctx = canvas.getContext('2d');
					var width = img.width;
					var height = img.height;

					var width2 = width;
					var height2 = height;
					if(width >= height) {
						height2 = maxsize;
						width2 = Math.ceil(((width*height2))/height);
					} else {
						width2 = maxsize;
						height2 =  Math.ceil(((height*width2))/width);
					}

					var pi = Math.PI;
					if(ori == "6") {
						canvas.width = height2;
						canvas.height = width2;
						ctx.translate(canvas.width/2, canvas.height/2);
						ctx.rotate(pi * 0.5);
						ctx.drawImage(img, -width2/2, -height2/2, width2, height2);
						var t = width2;
						width2 = height2;
						height2 = t;
					} else if(ori == "8") {
						canvas.width = height2;
						canvas.height = width2;
						ctx.translate(canvas.width/2, canvas.height/2);
						ctx.rotate(pi * 1.5);
						ctx.drawImage(img, -width2/2, -height2/2, width2, height2);
						var t = width2;
						width2 = height2;
						height2 = t;
					} else if(ori == "3") {
						canvas.width = width2;
						canvas.height = height2;
						ctx.translate(canvas.width/2, canvas.height/2);
						ctx.rotate(pi);
						ctx.drawImage(img, -width2/2, -height2/2, width2, height2);
					} else {
						canvas.width = width2;
						canvas.height = height2;
						ctx.drawImage(img, 0, 0, width2, height2);
					
					}

					var dataURL = canvas.toDataURL("image/jpeg", 0.9);
					form.picdata.value = dataURL;
					form.file.value = '';
				}
				$G.submitForm(fname);
			}

		}
		return ;
	}
	
	
	$G.submitForm(fname);

}
function isPicFn(fn) {
	fn = fn.toLowerCase();
	if(fn.endsWith(".jpg") || fn.endsWith(".jpeg") || fn.endsWith(".bmp") || fn.endsWith(".png") || fn.endsWith(".gif")) return true;
	return false;
}
function showUploadList(path, name, formname, multiple, multiple_split, notedit, upload_prefix) {
	
	if(!notedit || notedit == '') $("edit_" + name).value = path;
	if(!upload_prefix) upload_prefix = '';
	if(multiple == '1') {
		var html = '';
		if(path != '') {
			var a = path.split(multiple_split);
			for(var i = 0; i < a.length; i++) {
				var p = a[i];
				var po = p;
				if(upload_prefix != '') {
					p = upload_prefix + p;
				}
				var title = isPicFn(p)?"查看图片":"点击下载";
				html += '<a href="javascript:;" onclick="open_url(\''+$G.htmlspecialchars(p)+'\')" style="color:blue;text-decoration:underline">'+title+''+(i+1)+'</a>';
				if(!notedit || notedit == '') html += ' <a href="javascript:;" onclick="clearUpload(\''+po+'\', \''+name+'\', \''+formname+'\', \''+multiple+'\', \''+multiple_split+'\', \''+upload_prefix+'\')" style="color:red;text-decoration:underline">X</a>';
				html += '&nbsp;&nbsp;';
			}
		}
		$("fname_" + name).innerHTML = html;
		if(!notedit || notedit == '') $("div_"+formname).style.display = '';
	} else {
		var patho = path;
		if(upload_prefix && upload_prefix != '') {
			path = upload_prefix + path;
		}
		var title = isPicFn(path)?"查看图片":"点击下载";
		var html = '<a href="javascript:;" onclick="open_url(\''+$G.htmlspecialchars(path)+'\')" style="color:blue;text-decoration:underline">'+title+'</a>';
		if(!notedit || notedit == '') html += ' <a href="javascript:;" onclick="clearUpload(\''+patho+'\', \''+name+'\', \''+formname+'\', \''+multiple+'\', \''+multiple_split+'\', \''+upload_prefix+'\')" style="color:red;text-decoration:underline">X</a>';
		$("fname_" + name).innerHTML = html;
		if(!notedit) $("div_"+formname).style.display = 'none';
	}
}
function clearUpload(path, name, formname, multiple, multiple_split, upload_prefix) {
	if(multiple == '1') {
		var path2 = $("edit_" + name).value;
		path2 = path2.replace(path+multiple_split, '');
		path2 = path2.replace(multiple_split+path, '');
		path2 = path2.replace(path, '');
		showUploadList(path2, name, formname, multiple, multiple_split, false, upload_prefix);
	} else {
		$('div_'+formname).style.display = '';
		$('fname_'+name).innerHTML = '';
		$('edit_'+name).value = '';
	}

}
function uploadFinish(path, name, formname, multiple, multiple_split, after_upload, upload_prefix) {
	if(path == '#fail') {
		alert("上传失败！");
		var t = document.forms[formname].upload_type.value;
		document.forms[formname].reset();
		document.forms[formname].upload_type.value = t;
		$("div_"+formname).style.display = '';
		$("fname_" + name).innerHTML = '';
	} else {
		if(multiple == '1') {
			var path2 = $("edit_" + name).value;
			if(path2 != '') path2 += multiple_split;
			path2 += path;
			path = path2;
		}
		showUploadList(path, name, formname, multiple, multiple_split, false, upload_prefix);
		var t = document.forms[formname].upload_type.value;
		document.forms[formname].reset();
		document.forms[formname].upload_type.value = t;
		
		if(after_upload && after_upload != '') {
			window[after_upload](name, path);
		}
	}
	
	
}


function open_showtype(item, post) {
	if(!post) post = {};
	var url;
	var isshowtype = false;
	if(typeof(item['url_ifr']) != 'undefined') {
		url = item['url_ifr'];
		$("mainDiv").innerHTML = '<iframe width="100%" height="100%" frameborder="0" scrolling="yes" src="" name="main" id="main"></iframe>';
		$G.httpPost(url, {}, 'main');
		return ;
	}
	if(typeof(item['config']) != 'undefined') {
		isshowtype = true;
		showtype = item['config'];
		url = '?act=list_frame&showtype=' + showtype;
	} else if(typeof(item['url']) != 'undefined') {
		showtype = '';
		url = item['url'];
	} else if(typeof(item['location']) != 'undefined') {
		showtype = '';
		url = item['location'];
		//location.href = url;
		if(typeof(item['get']) != 'undefined') {
			location.href = url;
		} else {
			$G.httpPost(url, {}, '_self');
		}
		
		return;
	} else if(typeof(item['url_open']) != 'undefined') {
		showtype = '';
		url = item['url_open'];
		//window.open(url);
		$G.httpPost(url, {}, '_blank');
		return;
	} else if(typeof(item['js']) != 'undefined') {
		eval(item['js']);
		return;
	}
	$("mainDiv").innerHTML = '';
	$G.ajax(url, post, function(rs) {
		if(!check_rs(rs)) return ;
		$("mainDiv").innerHTML = rs.data.html;
		if(isshowtype) {
			search_items =  rs.data.search_items;
			editheight =  rs.data.editheight;
			editparam = rs.data.editparam;
			show_loading =  rs.data.show_loading;
			
			window.checkBefore = null;
			window.checkMore = null;
			var extraJs =  rs.data.extraJs;
			if(extraJs && extraJs != '') {
				if($("listScript")) {
					$G.rm("listScript");
				}
				if(typeof(execScript) != 'undefined') {
					execScript(extraJs);
				} else {
					var newScript = document.createElement('script');
					newScript.type = 'text/javascript';
					newScript.innerHTML = extraJs;
					newScript.id = "listScript";
					document.head.appendChild(newScript);
				}
				
			}

			if(!search_items || search_items == '') search_items = false;
			
			lastPage = 1;
			lastSearchParams = {};
			search();
		}

	}, 'json', 'POST');
}

function doLogout() {
	LocalStorage.removeItem(config_prefix+'_admininc_token');
	window.location.href = "?act=login";
	window.event.returnValue=false;
}

function repass() {
	var oldpw = $G.getValue("oldpw");
	var newpw1 = $G.getValue("newpw1");
	var newpw2 = $G.getValue("newpw2");
	if(oldpw == '') {
		alert("请填写原密码！");
		return ;
	}
	if(newpw1 == '') {
		alert("请填写新密码！");
		return ;
	}
	if(newpw2 == '') {
		alert("请再次填写新密码！");
		return ;
	}
	if(newpw1 != newpw2) {
		alert("两次填写的新密码不一致！");
		return ;
	}
	$("bt").disabled = true;
	$G.ajax("?act=repass&m=submit", {'oldpw': oldpw, 'newpw': newpw1}, function(rs) {
		$("bt").disabled = false;
		if(!check_rs(rs)) return ;
		alert("修改密码成功！");
		$G.setValue("oldpw");
		$G.setValue("newpw1");
		$G.setValue("newpw2");

	}, 'json', 'POST');
}

function openIfr(title, url, w, h, nopost, noscroll) {
	<? if($isphone) { ?>
		w = parseInt(document.documentElement.clientWidth*0.9);
		h = parseInt(document.documentElement.clientHeight*0.8);
	<? } ?>
	$("fdiv_ifr_title").innerHTML = title;
	$("fdiv_ifr").style.width = w + 'px';
	$("fdiv_ifr").style.height = h + 'px';
	$("fdiv_ifr_1").style.height = (h-28) + 'px';
	$("fdiv_ifr_id").setAttribute("width", w+"");
	$("fdiv_ifr_id").setAttribute("height", (h-28)+"");
	$("fdiv_ifr_id").style.height = (h-28) + 'px';
	$("fdiv_ifr_id").style.width = w + 'px';


	if(!nopost) $G.httpPost(url, {}, 'fdiv_ifr_id');
	else $("fdiv_ifr_id").src = url;

	if(!noscroll) $("fdiv_ifr_id").setAttribute("scrolling", "auto");
	else $("fdiv_ifr_id").setAttribute("scrolling", "no");
	$G.show_div("fdiv_ifr", w, h, 'ifr_cover', 16);
}

function openIfr_showtype(title, showtype, post, width, height) {
	<? if($isphone) { ?>
		height = parseInt(document.documentElement.clientHeight*0.8)-48;
	<? } else {?>
		height = height - 28;
	<? } ?>
	var url = '?act=newifr&height='+height;
	openIfr(title, url, width, height);

	$('fdiv_ifr_id').onload = function() {
		if(window.frames['fdiv_ifr_id'].open_showtype) {
			window.frames['fdiv_ifr_id'].open_showtype({"config": showtype}, post);
		}

	}
	hide_text_select();
}
function show_fdiv(width, height, title) {
	if(!title) title = '查看详情';
	var ch = Math.max(height, 150);

	$("fdiv").style.height = ch + 'px';
	$("fdiv_1").style.height = (ch-40) + 'px';
	
	<? if($isphone) { ?>
		width = parseInt(document.documentElement.clientWidth*0.9);
	<? } ?>

	
	$("fdiv").style.width = width + 'px';
	$("fdiv_1").style.overflowX = 'hidden';

	$("fdiv_title").innerHTML = title;
	$G.show_div("fdiv", width, ch);
}

function confirmImport(fkey) {
	$("cancelImportBt").style.display = 'none';
	$("confirmImportBt").value = "正在导入..";
	$("confirmImportBt").disabled = true;

	var post = {"fkey": fkey};
	if(editparam) {
		for(var k in editparam) {
			post[k] = editparam[k];
		}
	}


	$G.ajax('?act=import&showtype='+showtype, post, function(rs) {
		if(!check_rs(rs)) {
			$("cancelImportBt").style.display = '';
			$("confirmImportBt").value = "确认导入";
			$("confirmImportBt").disabled = false;

			return false;
		}
		alert(rs.message);
		hideInfo();
		getListData();
	}, 'json', 'POST');
}

function importFinish(msg, suc, formname) {
	var form = document.forms[formname];
	if(suc) {
		var pos1 = msg.indexOf('#');
		if(pos1 == -1) return ;
		var pos2 = msg.indexOf('#', pos1+1);
		if(pos2 == -1) return ;
		var fkey = msg.substr(0, pos1);
		var totalwidth = parseInt(msg.substr(pos1+1, pos2 - pos1 - 1));
		totalwidth += 100;
		
		$("infocontent").innerHTML = msg.substr(pos2+1);

		var width = document.documentElement.clientWidth;
		if(width == 0) width = document.body.clientWidth;
		
		var height = document.documentElement.clientHeight;
		if(height == 0) height = document.body.clientHeight;

		var scroll = false;
		if(totalwidth > width-100) {
			totalwidth = width-100;
			scroll = true;
		}

		show_fdiv(totalwidth, height-200, '预览 <input id="confirmImportBt" class="button" type="button" value="确认导入" style="cursor:pointer;background:#009900;margin-left:10px" onclick="confirmImport(\''+fkey+'\')" /><input id="cancelImportBt" class="button" type="button" value="重新上传" style="cursor:pointer;background:#2E4E95;margin-left:8px" onclick="showImport();" />');
		
		if(scroll) {
			$("fdiv_1").style.overflowX = 'scroll';
		}

		return ;
	} else {
		alert(msg);

		form.importbt.value = "导入";
		form.importbt.disabled = false;
		form.reset();


		//hideInfo();
		//getListData();
	}
}

function doImport(formname) {
	var form = document.forms[formname];
	var path = form.file.value;
	if(path == '') {
		alert("请选择要导入的Excel文件！");
		return ;
	}
	var a = path.split(".");
	if(a.length <= 1) return ;
	var ext = a[a.length - 1].toLowerCase();
	if(ext != 'xls' && ext != 'xlsx') {
		alert("只能上传xlsx或xls格式文件！");
		return ;
	}
	form.importbt.value = "正在上传..";
	form.importbt.disabled = true;
	$G.submitForm(formname);
}
function showImport(cover) {
	var es = "";
	var es2 = "";
	if(editparam) {
		for(var k in editparam) {
			es += '<input name="'+k+'" type="hidden" value="'+editparam[k]+'" />';
			if(es2 != '') es2 += ',';
			es2 += "'"+k+"':'"+editparam[k]+"'";
		}
	}
	var is_cover = (cover && cover == 1);
	var formname = "form_"+new Date().getTime();
	var html = '<div style="margin-top:20px;text-align:center">'+
		'<form method="post" name="'+formname+'" action="?act=import&showtype='+showtype+'&formname='+formname+'" enctype="multipart/form-data" target="uploadifr">' + es +
		'<input name="file" type="file" name="file" style="cursor:pointer; width:110px" />　'+
		'<input name="importbt" class="button" type="button" value="导入" style="cursor:pointer"  onclick="doImport(\''+formname+'\')" />　'+
		'<a href="javascript:;" onclick="$G.httpPost(\'?act=downtpl&showtype='+showtype+'\', {'+es2+'}, \'_self\')" style="color:'+(is_cover?"red":"blue")+'">Excel模板下载</a>'+
		'</form>';
	if(is_cover) {
		html += '<div style="margin-top:5px; color:blue">(导入会<span style="font-weight:bold;text-decoration:underline; color:red">清空</span>已有数据，请在导入Excel中添加<span style="font-weight:bold;text-decoration:underline; color:red">全量数据！</span>)</div>';
	}
	html += '</div>';
	$("infocontent").innerHTML = html;
	show_fdiv(500, 150, '导入');
}

function doBt_m(showtype, id, m, tip, more) {
	if(tip && tip != '') {
		if(!confirm(tip)) return ;
	}
	$G.ajax("?act=show&showtype="+showtype+"&m="+m+more, {"id": id}, function(rs) {
		if(!check_rs(rs)) return false;
		getListData();
	}, 'json', 'POST');
}
var last_show_text_select_zd = '';
var show_text_select_stop = false;
function show_text_select(obj, zd, func) {
	var id = 'text_selec_div';
	if($(id)) {
		if(last_show_text_select_zd == zd) return ;
		$G.rm(id);
	}
	if(show_text_select_stop) {
		show_text_select_stop = false;
		return ;
	}
	last_show_text_select_zd = zd;
	var div = document.createElement("div");
	div.setAttribute('onclick', '$G.stopBubbling(event);');
	var w = obj.offsetWidth;
	if(w < 200) w = 200;
	var h = 200;
	var left = $G.getElementLeft(obj);
	var top = $G.getElementTop(obj) + obj.offsetHeight + 5;
	var selectdata;
	if(func) {
		selectdata = func();
	} else {
		selectdata = JSON.parse(decodeURIComponent(obj.getAttribute("selectdata")));
	}
	if(selectdata == null || !selectdata || selectdata.length == 0) return ;

	div.style.cssText = 'position:absolute; z-index:100; left:'+left+'px; top:'+top+'px; width:'+w+'px; height:'+h+'px; border:1px solid #bbbbbb; border-radius:7px;box-shadow: 0px 0px 10px 5px #aaaaaa; background:#ffffff; overflow:hidden';
	div.id = id;

	var listHtml = '';
	for(var i = 0; i < selectdata.length; i++) {
		var value = selectdata[i];
		listHtml += '<div onclick="$G.setValue(\''+zd+'\', \''+value+'\');hide_text_select()" style="padding:5px 5px; text-align:center; cursor:pointer; border-bottom:1px solid #dddddd;color:#666666" onmouseover="this.style.backgroundColor=\'#1C91FF\';this.style.color=\'white\'" onmouseout="this.style.backgroundColor=\'\';this.style.color=\'#666666\'">'+value+'</div>';
	}

	div.innerHTML = '<div style="border-bottom:1px solid #dddddd; height:35px; background:#f5f5f5"><div style="float:left; padding:5px 5px"><input type="text" placeholder="搜索" style="width:'+(isphone?"60":"100")+'px; height:20px;border:1px solid #bbbbbb; border-radius:7px;padding-left:10px" oninput="search_text_select(this)" /></div><div style="float:right; padding:5px 5px;color:#666666"><img src="?act=getjscss&fn=images%2fclear.png" width="17" height="19" style="vertical-align:middle;cursor:pointer;margin-top:3px;margin-right:2px" onclick="hide_text_select();show_text_select_stop=true;$(\''+zd+'\').focus();" /></div></div><div style="width:100%; height:'+(h-35)+'px; overflow-x:hidden; overflow-y:scroll">'+listHtml+'</div>';
	document.body.appendChild(div);
}
function hide_text_select() {
	var id = 'text_selec_div';
	last_show_text_select_zd = '';
	if($(id)) {
		$G.rm(id);
	}
}
function search_text_select(obj) {
	var v = $G.trim(obj.value);
	var div = obj.parentNode.parentNode.nextSibling;
	var a = div.getElementsByTagName("div");
	for(var i = 0; i < a.length; i++) {
		var div1 = a[i];
		if(v == '' || div1.innerHTML.indexOf(v) != -1) {
			div1.style.display = '';
		} else {
			div1.style.display = 'none';
		}
	}
}
function click_hide_text_select() {
	var id = 'text_selec_div';
	if(last_show_text_select_zd == '' || !$(id)) {
		return ;
	}
	if(event.target.id != last_show_text_select_zd) {
		hide_text_select();
	}
}
function showMenus() {
	$G.cover();
	$("fdiv_menus").style.display = 'block';
	$("fdiv_menus").style.opacity = '0';
	$("fdiv_menus").style.transition = 'opacity 0.3s ease';
	var h = $("fdiv_menus").scrollHeight;

	var height = document.documentElement.clientHeight;
	if(height == 0) height = document.body.clientHeight;

	if(h > height - 120) h = height - 120;

	$("fdiv_menus").style.height = h+'px';
	void $("fdiv_menus").offsetWidth;
	$("fdiv_menus").style.opacity = '1';
	$("cover_div_dasda").addEventListener('click', function() {
		hideMenus();
	});
}
function hideMenus() {
	if($("fdiv_menus").style.display != 'block') return ;
	$G.uncover();
	$("fdiv_menus").style.display = 'none';
}